/**
 * Progress bar
 */
const { app } = require('electron')

module.exports = (win) => {
  const INCREMENT = 0.03
  const INTERVAL_DELAY = 100 //ms

  let c = 0
  let progressInterval = setInterval(() => {
    win.setProgressBar(c)

    if (c < 2) {
      c += INCREMENT
    } else {
      c = (-INCREMENT * 5)
    }
  }, INTERVAL_DELAY)

  app.on('before-quit', () => {
    clearInterval(progressInterval)
  })
}